<?php

error_reporting(E_ALL|E_STRICT);

set_include_path('.' . PATH_SEPARATOR . './application/models/' . PATH_SEPARATOR . './application/plugins' . PATH_SEPARATOR .get_include_path());



require_once 'Zend/Session.php';
// Include loader class, this way we don't have to use require statements
include_once("Zend/Loader.php");

Zend_Session::start();
// Set up Zend_session
Zend_Loader::loadClass('Zend_Session_Namespace');
$reg = new Zend_Session_Namespace();

// Get configuration data
Zend_Loader::loadClass('Zend_Config_Ini');
$config = new Zend_Config_Ini('config.ini', 'filesystem');
$reg->config = $config;


// Set timezone - from config.ini
date_default_timezone_set($config->default_timezone);



// setup controller
Zend_Loader::loadClass('Zend_Controller_Front');

$frontController = Zend_Controller_Front::getInstance();
$frontController ->throwExceptions(true);
$frontController ->setControllerDirectory($config->controller_dir)
				 ->setBaseUrl($config->base_url);
	

			 
				 
// Set the default router to handle language requests.
// route will be: lang/controller/action
				 
				 
				 
$controller = 'index';
$action = 'index';
$router = $frontController->getRouter();
$route = new Zend_Controller_Router_Route(
    ':lang/:controller/:action',
    array('controller' => $controller, 'action' => $action
    )
);

$router->addRoute('default', $route);




						
// Create new view 
Zend_Loader::loadClass('Zend_View');
$view = new Zend_View();
$view->addHelperPath('application/views/helpers/', 'Escape_View_Helper');



//Create viewHelper
Zend_Loader::loadClass('Zend_Controller_Action_Helper_ViewRenderer');
$viewHelper = new Zend_Controller_Action_Helper_ViewRenderer($view);
$viewHelper->setViewSuffix('tpl')
		   ->setNeverController(false);

//Save the helper to the HelperBroker
Zend_Controller_Action_HelperBroker::addHelper($viewHelper);


/////////////////////////////////////////////////////////////////////////////////
// Assign global template vars

$view->base_url = $config->base_url;
$view->images_url = $config->server_name.$config->base_url.$config->images_url;



$frontController->returnResponse(true);
$response = $frontController->dispatch();



// Set HTTP headers to correct charset

$response->setHeader('Content-type', 'text/html; charset=utf-8;');


// run!
$response->sendResponse();
